package nginx_handler

import (
	fmkconst "gitee.com/zaper/software-framework/constant"
	"os"
	"strconv"
)

var NginxConf string

func GetNginxConf() {
	mode := getTlsMode()
	if mode == fmkconst.Oneway {
		NginxConf = "conf/nginx_oneway.conf"
		return
	}
	NginxConf = "conf/nginx_mutual.conf"
}

func getTlsMode() int {
	tlsMode := os.Getenv(fmkconst.TlsMode)
	if tlsMode == "" {
		return fmkconst.Mutual
	}
	mode, err := strconv.ParseInt(tlsMode, 10, 32)
	if err != nil {
		return fmkconst.Mutual
	}
	if mode == fmkconst.Oneway {
		return fmkconst.Oneway
	} else {
		return fmkconst.Mutual
	}
}
